# add swig java
find_package(SWIG REQUIRED)
include(UseSWIG)

find_package(Java REQUIRED)
find_package(JNI REQUIRED)
include(UseJava)
include_directories(${JNI_INCLUDE_DIRS})

set(CMAKE_SWIG_FLAGS -package com.artosyn.ar8030)
set(CMAKE_SWIG_OUTDIR ${CMAKE_CURRENT_SOURCE_DIR}/com/artosyn/ar8030)

swig_add_library(daemon_java
    TYPE SHARED
    LANGUAGE java
    SOURCES daemon.i
)

target_include_directories(daemon_java PRIVATE ${JAVA_INCLUDE_PATH})
target_include_directories(daemon_java PRIVATE ./)
swig_link_libraries(daemon_java ${JAVA_LIBRARIES} daemon)

# build & install wrap.jar
get_property(daemon_java_file TARGET daemon_java PROPERTY SWIG_SUPPORT_FILES)
add_jar(daemonjni SOURCES ${daemon_java_file} OUTPUT_NAME daemon_java)
add_dependencies(daemonjni daemon_java)
install_jar(daemonjni DESTINATION java)

# install wrap jni shared library
install(TARGETS daemon_java
    DESTINATION java
)
